package main

import "fmt"

func printMap(cityMap map[string]string) {
	//cityMap是一个引用传递
	for key, value := range cityMap {
		fmt.Println("key=", key)
		fmt.Println("value=", value)
	}

	cityMap["china"] = "shenzhen"
	cityMap["england"] = "london"
}

func main() {

	cityMap := make(map[string]string)

	cityMap["china"] = "beijing"
	cityMap["japan"] = "tokyo"
	cityMap["usa"] = "NewYork"

	//遍历
	for key, value := range cityMap {
		fmt.Println("key=", key)
		fmt.Println("value=", value)
	}

	//删除
	delete(cityMap, "china")

	//修改
	cityMap["usa"] = "dc"

	fmt.Println("==========")

	for key, value := range cityMap {
		fmt.Println("key=", key)
		fmt.Println("value=", value)
	}

	printMap(cityMap)
	fmt.Println("==========")

	for key, value := range cityMap {
		fmt.Print("key=", key)
		fmt.Println(",value=", value)
	}

}
